package com.epam.manager;

import com.epam.client.backingbeans.ClosedRequestBean;
import com.epam.entity.Bill;
import com.epam.entity.Car;
import com.epam.entity.Status;
import com.epam.manager.bakingbeans.ActiveRequestManagedBean;
import com.epam.manager.bakingbeans.AdminLoginBean;
import com.epam.manager.bakingbeans.NewRequestManagedBean;

public class ManagerController {

	private ActiveRequestManagedBean activeRequestManagedBean;
	private AdminLoginBean adminLoginBean;
	private ClosedRequestBean closedRequestBean;
	private NewRequestManagedBean newRequestManagedBean;
	
	public void closeRequest() {
//		log.debug("request " + request);
//		request.setStatus(Status.CLOSED);
//		requestDAO.update(request);
//
//		Car car = request.getCar();
//		car.setIsAvaliable(true);
//		carDAO.update(car);
	}
//ActiveRequestManagedBean
	public void makeAdditionalBill() {	
//		bill.setRequest(request);
//		bill.setStatus(Status.NOT_PAYED);
//		billDAO.create(bill);
	}
//ClosedRequestBean
	public void updateRequest() {
//		log.debug("ClosedRequestManagedBean updateRequest " + request);
//		requestDAO.update(request);
	}
//NewRequestManagedBean	
	public void cancelRequest() {
//		request.setStatus(Status.CANCELLED);
//		requestDAO.update(request);
//
//		Car car = request.getCar();
//		car.setIsAvaliable(true);
//		carDAO.update(car);
	}

	public void approveRequest() {
//		request.setStatus(Status.APPROVED);
//
//		long days = (request.getEndDate().getTime() - request.getBeginDate()
//				.getTime()) / (1000 * 60 * 60 * 24);
//
//		double sum = request.getCar().getRentRate() * days;
//		sum *= 100;
//		sum = (double) Math.round(sum) / 100;
//
//		Bill bill = new Bill(request, sum, Status.NOT_PAYED, "RENT PAYMENT");
//		billDAO.create(bill);
//
//		requestDAO.update(request);
	}
	
}
